The reason I suggest this is that scripts and styles within the template
would no longer need escaping:
function test()
{
{if $foo == $bar}alert('foo = bar');{else}alert('foo != bar'){/if}
}
or
.bg {
background-color: {$bgcolor};
color: {$fgcolor};
}
Actually it's only after the opening brace that really matters, it's not
ambiguous to allow whitespace before the closing brace.
I know that the delimiter can be changed, but using {} is easy to read
and consistent with existing templates.
--
Mark Rogers // More Solutions Ltd (Peterborough Office) // 0845 45 89 555
Registered in England (0456 0902) at 13 Clarke Rd, Milton Keynes, MK1 1LG
FYI also, I wrote a {script} pre-processor which replaced any { which
was followed by whitespace with {ldelim}, and any } preceded by
whitespace by {rdelim}, so that the code examples I wrote previously
would work as written. I have since realised that (a) I rarely need
{literal} any more now that I have {script}, and (b) I don't have to
"think" inside the {script}..{/script} block about what works and what
doesn't, it just works "naturally". Which is why I think having that
functionality everywhere by default makes life much easier.
.bg {
background-color: {$bgcolor};
color: {$fgcolor};
}
Will work, no errors. $bgcolor and $fgcolor will get parsed, the other
delims are ignored.
Michael Hurni wrote:
> It's a nice way too..
> I will use yours
>
> in future smarty3 ?
>
> Michael
>
>
> 2008/10/24 Mark Rogers <ma...@quarella.co.uk <mailto:ma...@quarella.co.uk>>
Does this mean that whitespaces after left delimiters are invalid in
3.0? If so this will surely break a lot of existing templates.
Frank
I've not had chance to experiment with Smarty 3 yet, but is it not
possible to define "{ " and " }" as the Smarty delimiters in Smarty 3?
It would mean that {$x} would no longer be picked up by Smarty but if
you've been consistent and always used { $x } that should fix it?
Whether or not it would be possible to define regex delimiters like {\s*
and \s*} I also have no idea, but something like that might make it
possible to support both forms.
Personally I love the new format:
<style>
.table-content: { color: {$color}; }
</style>